package com.ztgf.shopping.api.client.shop;

import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.service.shop.IShopGoodsCountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
 * @author: chenyu.wang
 * @date: 2020-08-19
 * @description:卖家店铺产品统计控制器
 */
@RestController
@RequestMapping("/api/shopGoodsCountApi")
@Api(value = "ShopGoodsCountApiController", tags = "卖家店铺产品统计接口")
public class ShopGoodsCountApiController {

    @DubboReference
    private IShopGoodsCountService shopGoodsCountService;

    @PostMapping(value = "/queryShopGoodsCount")
    @ApiOperation(value = "统计店铺各状态商品数量", notes = "统计店铺各状态商品数量")
    private Result queryShopGoodsCount(Long shopId) {
        if (shopId == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopGoodsCountService.queryShopGoodsCount(shopId));
    }

    @PostMapping(value = "/queryShopSalesRanks")
    @ApiOperation(value = "店铺运营产品统计销量排名", notes = "店铺运营产品统计销量排名")
    private Result queryShopSalesRanks(Integer pageNo, Integer pageSize, Long shopId) {
        if (shopId == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopGoodsCountService.queryShopSalesRanks(pageNo, pageSize, shopId));
    }

    @PostMapping(value = "/queryShopGoodsNew")
    @ApiOperation(value = "店铺运营产品统计最近上新", notes = "店铺运营产品统计最近上新")
    private Result queryShopGoodsNew(Integer pageNo, Integer pageSize, Long shopId) {
        if (shopId == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopGoodsCountService.queryShopGoodsNew(pageNo, pageSize, shopId));
    }
}
